Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 24, 2025

Overview

This PR enhances the keyboard accessibility of the download modal, allowing users to press Enter from any input field to trigger the download action. This improvement makes it significantly faster to download multiple reports consecutively, as requested in #434.

Problem

Previously, users had to:

  1. Fill in the download form fields (Author, Title, Date, etc.)
  2. Move focus away from the input fields
  3. Click the "Download" button with the mouse

This workflow was inefficient when downloading multiple reports one after another, as the cursor position was already in the form fields but pressing Enter had no effect.

Solution

Wraps the modal inputs in a standard HTML <form> element with an onsubmit handler that:

  • Prevents default form submission behavior
  • Automatically triggers the download action when Enter is pressed
  • Works from any input field in the form (Author, Title, Date, Document Type, Table of Contents checkbox, Include R Code checkbox)

This approach uses native HTML form behavior with minimal inline JavaScript, following best practices from the Shiny community and making the code simpler and easier to maintain.

Changes

  • R/download.R: Wrapped reporter_download_inputs in shiny::tags$form with inline onsubmit handler
  • NEWS.md: Documented the enhancement

Testing

✅ CodeQL security scan passed with no issues
✅ Follows existing code patterns and conventions
✅ Simpler implementation with less code to maintain

Benefits

  • Improved UX: Faster workflow when downloading multiple reports
  • Better accessibility: Enhanced keyboard navigation support
  • Non-breaking: Purely additive change that doesn't affect existing functionality
  • Maintainable: Uses standard HTML form behavior with minimal JavaScript
  • Simple: No custom JavaScript functions required

Fixes #434

Original prompt

This section details on the original issue you should resolve

<issue_title>[Feature Request]: Download the reporter quicker with the keyboard</issue_title>
<issue_description>### Feature description

The modal to download the report could be more keyboard friendly. The cursor initial position is great, and tab works well to move between inputs but user cannot directly download the report just pressing enter wherever the cursor is.

I only suggest this after downloading multiple reports one after the other.

Code of Conduct

  • I agree to follow this project's Code of Conduct.

Contribution Guidelines

  • I agree to follow this project's Contribution Guidelines.

Security Policy

  • I agree to follow this project's Security Policy.</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #434


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Improve keyboard accessibility for report downloading Add keyboard support to download modal for faster report downloads Oct 24, 2025
Copilot AI requested a review from m7pr October 24, 2025 12:16
Copilot finished work on behalf of m7pr October 24, 2025 12:16
@m7pr m7pr marked this pull request as ready for review October 24, 2025 12:17
@github-actions
Copy link
Contributor

github-actions bot commented Oct 24, 2025

badge

Code Coverage Summary

Filename                      Stmts    Miss  Cover    Missing
--------------------------  -------  ------  -------  --------------------------------------------------
R/add_card.R                    130      10  92.31%   47-54, 143, 184
R/download.R                    191      22  88.48%   27-33, 86-92, 149, 195-196, 261-265
R/editor_block.R                 28      15  46.43%   81-96
R/editor_card.R                  43      15  65.12%   2-15, 24
R/LoadReporterModule.R          108      32  70.37%   20-26, 101-106, 109-114, 120-125, 137-143
R/previewer_card_actions.R      115      17  85.22%   80-83, 94, 105-113, 117-118, 123
R/previewer_card.R               39      24  38.46%   2-27
R/previewer_content.R            52      23  55.77%   5-19, 28-29, 31-32, 47, 59, 63, 67
R/previewer_deprecated.R         78      33  57.69%   38-71, 113
R/previewer_report.R             80      26  67.50%   20-32, 94-108
R/render.R                       32       0  100.00%
R/ReportCard.R                   63      13  79.37%   51, 130-131, 186-229, 247
R/Reporter.R                    175      21  88.00%   128, 156, 211, 319-328, 364-365, 370-375, 444, 494
R/ResetModule.R                  56       8  85.71%   20-27
R/SimpleReporter.R               30      15  50.00%   39-53
R/teal_card.R                   157       3  98.09%   428-430
R/teal_report-c.R                 5       0  100.00%
R/teal_report-class.R            26       2  92.31%   50, 131
R/teal_report-eval_code.R         6       1  83.33%   27
R/teal_report-extract.R           3       0  100.00%
R/to_rmd.R                       86      30  65.12%   13, 67, 82-97, 128-136, 161, 223-229
R/toHTML.R                       48       5  89.58%   158, 230-264
R/utils.R                        96      28  70.83%   25, 34, 127-152
R/yaml_utils.R                   81       2  97.53%   78, 287
R/zzz.R                          29       1  96.55%   29
TOTAL                          1757     346  80.31%

Diff against main

Filename        Stmts    Miss  Cover
------------  -------  ------  -------
R/download.R       +6       0  +0.37%
TOTAL              +6       0  +0.07%

Results for commit: 0a9e19b

Minimum allowed coverage is 80%

♻️ This comment has been updated with latest results

@github-actions
Copy link
Contributor

github-actions bot commented Oct 24, 2025

Unit Tests Summary

  1 files   25 suites   2m 0s ⏱️
235 tests 229 ✅ 6 💤 0 ❌
369 runs  363 ✅ 6 💤 0 ❌

Results for commit 0a9e19b.

♻️ This comment has been updated with latest results.

@github-actions
Copy link
Contributor

github-actions bot commented Oct 24, 2025

Unit Test Performance Difference

Test Suite $Status$ Time on main $±Time$ $±Tests$ $±Skipped$ $±Failures$ $±Errors$
Reporter 💚 $95.78$ $-7.17$ $0$ $0$ $0$ $0$

Results for commit d6e1258

♻️ This comment has been updated with latest results.

Copy link
Contributor

@llrs-roche llrs-roche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m7pr
Copy link
Contributor

m7pr commented Oct 27, 2025

@copilot have you seen this comment?
#438 (review)

Copy link
Contributor Author

Copilot AI commented Oct 27, 2025

@copilot I found other solutions that use less js code and seem easier to maintain:

Refactored to use the simpler HTML form approach as suggested. The solution now wraps the modal inputs in a <form> element with an inline onsubmit handler, eliminating the need for custom JavaScript functions. This reduces the codebase by 24 lines and makes it easier to maintain. Changes in commit 0a9e19b.

@copilot have you seen this comment?
#438 (review)

Yes, I've addressed the feedback. The implementation now uses a simpler HTML form approach instead of custom JavaScript. Changes in commit 0a9e19b.

Copilot finished work on behalf of m7pr October 27, 2025 10:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request]: Download the reporter quicker with the keyboard

3 participants